<?php
$this->title = '修改密码';
$this->params['menu'] = [];
$this->params['breadcrumb'] = ['个人中心', '修改密码'];
$admin = \Yii::$app->user->identity;
?>
<?php $this->beginBlock('js_plugin') ?>
<script src="<?= Yii::$app->params['domains']['public']?>/plugin/jquery/validate/validate.min.js"></script>
<script src="<?= Yii::$app->params['domains']['public']?>/plugin/jquery/form.min.js"></script>
<?php $this->endBlock() ?>
<?php $this->beginBlock('actions') ?>
<a class="btn btn-info btn-white" href="center"><i class="ace-icon fa fa-reply"></i> 返回</a>
<?php $this->endBlock() ?>
<form class="form-horizontal" id="formChangePasswd" role="form" method="post">
    <div class="form-body">
        <div class="form-group">
            <label class="control-label col-xs-4"><b>*</b> 原密码</label>
            <div class="col-xs-3">
                <div>
                    <input type="password" name="old_passwd" autocomplete="off" class="width-100" />
                </div>
                <div class="help-info"></div>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-4"><b>*</b> 新密码</label>
            <div class="col-xs-3">
                <div>
                    <input type="password" name="new_passwd" autocomplete="off" class="width-100" />
                </div>
                <div class="help-info"></div>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-4"><b>*</b> 重复新密码</label>
            <div class="col-xs-3">
                <div>
                    <input type="password" name="re_passwd" autocomplete="off" class="width-100" />
                </div>
                <div class="help-info"></div>
            </div>
        </div>
    </div>
    <div class="form-actions fixed-bottom">
        <button class="btn btn-info" type="submit"><i class="ace-icon fa fa-check bigger-110"></i>提交</button>
        <button class="btn" type="reset"><i class="ace-icon fa fa-undo bigger-110"></i>重置</button>
    </div>
</form>
<?php $this->beginBlock('js') ?>
<script type="text/javascript">
    $('#formChangePasswd').jqvalidate({
        rules: {
            old_passwd: {required: true},
            new_passwd: {required: true},
            re_passwd: {required: true, equalTo: 'input[name=new_passwd]'},
        },
        messages: {},
        submitHandler: function (form) {
            $(form).ajaxSubmit({
                dataType : "json",
                success: function(response) {
                    if (response.code==0) {
                        layer.msg('保存成功', {icon: 1}, function(){
                            window.location.href = 'list';
                        });
                    }else{
                        layer.msg(response.msg, {icon: 2});
                    }
                },
                error: function(xhr, status, error) {
                    if(status==='error'){
                        layer.msg('服务器错误', {icon: 2});
                    }
                }
            });
        }
    })
</script>
<?php $this->endBlock() ?>